package com.hzcx.app.simplechat.model;

import android.content.Context;

import com.hzcx.app.simplechat.api.APIRequest;
import com.hzcx.app.simplechat.api.BaseObserver;
import com.hzcx.app.simplechat.api.RxHelper;
import com.hzcx.app.simplechat.base.BaseEmptyBean;
import com.hzcx.app.simplechat.ui.setting.bean.AutoSendMessageBean;
import com.hzcx.app.simplechat.ui.setting.bean.BatchClearListBean;
import com.hzcx.app.simplechat.ui.setting.bean.BlackListBean;
import com.hzcx.app.simplechat.ui.setting.bean.GroupMessageListBean;
import com.hzcx.app.simplechat.ui.setting.bean.ReportBean;
import com.hzcx.app.simplechat.ui.setting.bean.SettingFindMyWayBean;
import com.hzcx.app.simplechat.ui.setting.bean.VipInfoBean;
import com.hzcx.app.simplechat.ui.setting.bean.VipSettingBean;
import com.hzcx.app.simplechat.util.token.TokenUtils;

import java.util.List;

public class SettingModel {

    /**
     * 修改手机号
     *
     * @param context
     * @param mobile
     * @param captcha
     * @param area_code
     * @param observer
     */
    public static void updatePhone(Context context, String mobile, String captcha, String area_code, BaseObserver<BaseEmptyBean> observer) {
        updatePhone(context, TokenUtils.getTokenHeader(), mobile, captcha, area_code, observer);
    }

    /**
     * 修改手机号
     *
     * @param context
     * @param mobile
     * @param captcha
     * @param area_code
     * @param observer
     */
    public static void updatePhone(Context context, String token, String mobile, String captcha, String area_code, BaseObserver<BaseEmptyBean> observer) {
        APIRequest
                .getRequestInterface()
                .updatePhone(token, mobile, captcha, area_code)
                .compose(RxHelper.observableIO2Main(context))
                .subscribe(observer);
    }

    /**
     * 获取举报内容列表
     *
     * @param context
     * @param observer
     */
    public static void getReportList(Context context, BaseObserver<List<ReportBean>> observer) {
        APIRequest
                .getRequestInterface()
                .getReportList(TokenUtils.getTokenHeader())
                .compose(RxHelper.observableIO2Main(context))
                .subscribe(observer);
    }

    /**
     * 提交举报信息
     *
     * @param context
     * @param member_id
     * @param complaint_id
     * @param complaint_content
     * @param complaint_images
     * @param observer
     */
    public static void putReport(Context context, int member_id, int complaint_id, String complaint_content, String complaint_images, BaseObserver<BaseEmptyBean> observer) {
        APIRequest
                .getRequestInterface()
                .putReport(TokenUtils.getTokenHeader(), member_id, complaint_id, complaint_content, complaint_images)
                .compose(RxHelper.observableIO2Main(context))
                .subscribe(observer);
    }

    /**
     * 获取黑名单列表
     *
     * @param context
     * @param observer
     */
    public static void getBlackList(Context context, BaseObserver<List<BlackListBean>> observer) {
        APIRequest
                .getRequestInterface()
                .getBlackList(TokenUtils.getTokenHeader())
                .compose(RxHelper.observableIO2Main(context))
                .subscribe(observer);
    }

    /**
     * 提交意见反馈
     *
     * @param context
     * @param maincontent
     * @param feedimages
     * @param mobile
     * @param observer
     */
    public static void putFeedBack(Context context, String maincontent, String feedimages, String mobile, BaseObserver<BaseEmptyBean> observer) {
        APIRequest
                .getRequestInterface()
                .putFeedBack(TokenUtils.getTokenHeader(), maincontent, feedimages, mobile)
                .compose(RxHelper.observableIO2Main(context))
                .subscribe(observer);
    }

    /**
     * @param context
     * @param is_verification
     * @param is_allow
     * @param dy_auth
     * @param observer
     */
    public static void setPrivateConfig(Context context, String is_verification, String is_allow, String dy_auth, String is_auto, String way_type,
                                        BaseObserver<BaseEmptyBean> observer) {
        APIRequest
                .getRequestInterface()
                .setPrivateConfig(TokenUtils.getTokenHeader(), is_verification, is_allow, dy_auth, is_auto, way_type)
                .compose(RxHelper.observableIO2Main(context))
                .subscribe(observer);
    }

    /**
     * 获取群发助手列表
     *
     * @param context
     * @param page
     * @param observer
     */
    public static void getGroupMessageList(Context context, int page, BaseObserver<List<GroupMessageListBean>> observer) {
        APIRequest
                .getRequestInterface()
                .getGroupMessageList(TokenUtils.getTokenHeader(), page)
                .compose(RxHelper.observableIO2Main(context))
                .subscribe(observer);
    }

    /**
     * 群发消息
     *
     * @param context
     * @param chat_member_ids
     * @param type
     * @param maincontent
     * @param hxusernames
     * @param audio_time
     * @param observer
     */
    public static void sendGroupMessage(Context context, String chat_member_ids, int type, String maincontent, String hxusernames, int audio_time,
                                        BaseObserver<BaseEmptyBean> observer) {
        APIRequest
                .getRequestInterface()
                .sendGroupMessage(TokenUtils.getTokenHeader(), chat_member_ids, type, maincontent, hxusernames, audio_time)
                .compose(RxHelper.observableIO2Main(context))
                .subscribe(observer);
    }

    /**
     * 清空群发记录
     *
     * @param context
     * @param observer
     */
    public static void clearGroupMessage(Context context, BaseObserver<BaseEmptyBean> observer) {
        APIRequest
                .getRequestInterface()
                .clearGroupMessage(TokenUtils.getTokenHeader())
                .compose(RxHelper.observableIO2Main(context))
                .subscribe(observer);
    }

    /**
     * 重新发送群发消息
     *
     * @param context
     * @param id
     * @param type
     * @param maincontent
     * @param auido_time
     * @param observer
     */
    public static void reSendGroupMessage(Context context, int id, int type, String maincontent, int auido_time, BaseObserver<BaseEmptyBean> observer) {
        APIRequest
                .getRequestInterface()
                .reSendGroupMessage(TokenUtils.getTokenHeader(), id, type, maincontent, auido_time)
                .compose(RxHelper.observableIO2Main(context))
                .subscribe(observer);
    }

    /**
     * 添加或编辑自动回复消息
     *
     * @param context
     * @param host_type
     * @param maincontent
     * @param hostimage
     * @param host_id
     * @param observer
     */
    public static void addAutoSendMsg(Context context, int host_type, String maincontent, String hostimage, String host_id, BaseObserver<BaseEmptyBean> observer) {
        APIRequest
                .getRequestInterface()
                .addAutoSendMsg(TokenUtils.getTokenHeader(), host_type, maincontent, hostimage, host_id)
                .compose(RxHelper.observableIO2Main(context))
                .subscribe(observer);
    }

    /**
     * 获取自动回复列表
     *
     * @param context
     * @param observer
     */
    public static void getAutoSendMessageList(Context context, BaseObserver<List<AutoSendMessageBean>> observer) {
        APIRequest
                .getRequestInterface()
                .getAutoSendMessageList(TokenUtils.getTokenHeader())
                .compose(RxHelper.observableIO2Main(context))
                .subscribe(observer);
    }

    /**
     * 修改自动打招呼item是否选中
     *
     * @param context
     * @param id
     * @param observer
     */
    public static void updateAutoSendMsgItem(Context context, int id, BaseObserver<BaseEmptyBean> observer) {
        APIRequest
                .getRequestInterface()
                .updateAutoSendMsgItem(TokenUtils.getTokenHeader(), id)
                .compose(RxHelper.observableIO2Main(context))
                .subscribe(observer);
    }

    /**
     * 删除某一条自动打招呼消息
     *
     * @param context
     * @param id
     * @param observer
     */
    public static void deleteAutoSendMessageItem(Context context, int id, BaseObserver<BaseEmptyBean> observer) {
        APIRequest
                .getRequestInterface()
                .deleteAutoSendMessageItem(TokenUtils.getTokenHeader(), id)
                .compose(RxHelper.observableIO2Main(context))
                .subscribe(observer);
    }

    /**
     * 自动打招呼排序
     *
     * @param context
     * @param host_id
     * @param observer
     */
    public static void moveAutoSendMessage(Context context, String host_id, BaseObserver<BaseEmptyBean> observer) {
        APIRequest
                .getRequestInterface()
                .moveAutoSendMessage(TokenUtils.getTokenHeader(), host_id)
                .compose(RxHelper.observableIO2Main(context))
                .subscribe(observer);
    }

    /**
     * 获取查找我的方式列表
     *
     * @param context
     * @param observer
     */
    public static void getSettingFindMyWayList(Context context, BaseObserver<List<SettingFindMyWayBean>> observer) {
        APIRequest
                .getRequestInterface()
                .getSettingFindMyWayList(TokenUtils.getTokenHeader())
                .compose(RxHelper.observableIO2Main(context))
                .subscribe(observer);
    }

    /**
     * 绑定微信
     *
     * @param context
     * @param code
     * @param observer
     */
    public static void bindWechat(Context context, String code, BaseObserver<BaseEmptyBean> observer) {
        APIRequest
                .getRequestInterface()
                .bindWechat(TokenUtils.getTokenHeader(), code)
                .compose(RxHelper.observableIO2Main(context))
                .subscribe(observer);
    }

    /**
     * 获取会员信息
     *
     * @param context
     * @param observer
     */
    public static void getVipInfo(Context context, BaseObserver<VipInfoBean> observer) {
        APIRequest
                .getRequestInterface()
                .getVipInfo(TokenUtils.getTokenHeader())
                .compose(RxHelper.observableIO2Main(context))
                .subscribe(observer);
    }

    /**
     * 获取我的会员设置
     *
     * @param context
     * @param observer
     */
    public static void getMintVipSetting(Context context, BaseObserver<List<VipSettingBean>> observer) {
        APIRequest
                .getRequestInterface()
                .getMintVipSetting(TokenUtils.getTokenHeader())
                .compose(RxHelper.observableIO2Main(context))
                .subscribe(observer);
    }

    /**
     * 修改会员设置
     *
     * @param context
     * @param type
     * @param observer
     */
    public static void updateVipSetting(Context context, String type, BaseObserver<BaseEmptyBean> observer) {
        APIRequest
                .getRequestInterface()
                .updateVipSetting(TokenUtils.getTokenHeader(), type)
                .compose(RxHelper.observableIO2Main(context))
                .subscribe(observer);
    }

    /**
     * 批量清除
     *
     * @param context
     * @param observer
     */
    public static void batchClear(Context context, int cancel_id, BaseObserver<BaseEmptyBean> observer) {
        APIRequest
                .getRequestInterface()
                .batchClear(TokenUtils.getTokenHeader(), cancel_id)
                .compose(RxHelper.observableIO2Main(context))
                .subscribe(observer);
    }

    /**
     *  获取清除列表
     * @param context
     * @param type
     * @param observer
     */
    public static void getBatchClearList(Context context, int type, BaseObserver<List<BatchClearListBean>> observer) {
        APIRequest
                .getRequestInterface()
                .getBatchClearList(TokenUtils.getTokenHeader(), type)
                .compose(RxHelper.observableIO2Main(context))
                .subscribe(observer);
    }
}
